package com.henu.engineer.service;

import com.henu.engineer.dao.mapper.UserXmlMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author noexcept
 * @date 2021/7/26 6:34
 */
@Service
public class UserService {

    public static final Logger logger = LoggerFactory.getLogger("StudentService");

    /**
     * 学生
     */
    public static final String STUDENT = "student";
    /**
     * 普通教师
     */
    public static final String TEACHER = "teacher";
    /**
     * 课程组负责人
     */
    public static final String COURSE_LEADER = "course leader";
    /**
     * 专业负责人
     */
    public static final String PROFESSIONAL_LEADER = "professional leader";
    /**
     * 院级负责人
     */
    public static final String DEPART_LEADER = "depart leader";

    @Autowired
    UserXmlMapper userXmlMapper;

    /**
     * 更新密码
     * @param id
     * @param oldPwd 旧密码
     * @param newPwd 新密码
     * @return 是否成功
     */
    public String updatePwd(String id, String oldPwd, String newPwd) {
        if (!oldPwd.equals(userXmlMapper.selectPwd(id))) {
            return "原始密码输入错误！";
        }
        if (userXmlMapper.updatePwd(id, newPwd))
            return "修改成功！";
        else
            return "修改失败！";
    }

    public String selectPwd(String account){
        return userXmlMapper.selectPwd(account);
    }
}
